<?php
namespace app\admin\controller;

use think\Controller;
use think\facade\Cache;

class Base extends Controller
{
    protected function initialize()
    {
        parent::initialize();
        // 基础初始化逻辑
    }

    // 构建成功响应
    protected function buildSuccess($data = [], $msg = '操作成功', $code = 200)
    {
        return json([
            'code' => $code,
            'msg'  => $msg,
            'data' => $data
        ]);
    }

    // 构建失败响应
    protected function buildFailed($code = 400, $msg = '操作失败', $data = [])
    {
        return json([
            'code' => $code,
            'msg'  => $msg,
            'data' => $data
        ]);
    }

    // 获取区域信息
    protected function getAreaInfo()
    {
        // 区域信息获取逻辑
        return Cache::get('userarea');
    }
}